﻿<Window x:Class="_10.Commands.CopyCutPaste"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="CopyCutPaste" Height="178" Width="445">
    <DockPanel>
        <Menu DockPanel.Dock="Top">
            <!--note: using command can even ignore the header text, 
            after you set the command, WPF can even set the header text for you-->
            <!--note: not only TextBox know how to deal when specific menuitem clicked
            but also when there is change in selection of text in textbox, these menuitem
            know whether to enable or disable themself automatically-->
            <MenuItem Command="ApplicationCommands.Copy" Width="75" />
            <MenuItem Command="ApplicationCommands.Cut" Width="75" />
            <MenuItem Command="ApplicationCommands.Paste" Width="75" />
        </Menu>
        <GroupBox DockPanel.Dock="Bottom" Header="Commands Not Work On Buttons" Foreground="Red" FontWeight="Black">
            <Grid >
                <Grid.Resources>
                    <Style TargetType="Button">
                        <Setter Property="Margin" Value="5"/>
                    </Style>
                </Grid.Resources>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition  />
                    <ColumnDefinition  />
                </Grid.ColumnDefinitions>
                <!--note: pay another attention that, even I set the same command to button,
            but they don't work properly as they work on menuitem, so I guess the business
            logic to deal with specific commands are just embedded into specific controls, while
            not embedded into other controls-->
                <Button Grid.Row="0" Grid.Column="0" Command="ApplicationCommands.Copy">Copy</Button>
                <Button Grid.Row="0" Grid.Column="1" Command="ApplicationCommands.Cut">Cut</Button>
                <Button Grid.Row="0" Grid.Column="2" Command="ApplicationCommands.Paste">Paste</Button>
            </Grid>
        </GroupBox>
        <TextBox BorderBrush="Black" BorderThickness="2" Margin="10"
               TextWrapping="Wrap" DockPanel.Dock="Top">
            The MenuItem will not be enabled until
        this TextBox gets keyboard focus
        </TextBox>
    </DockPanel>

</Window>
